set(SUBLIB_NAME statusnotifierwatcher)
find_package(Qt5 REQUIRED COMPONENTS DBus)

#判断编译器类型,如果是gcc编译器,则在编译选项中加入c++11支持
if(CMAKE_COMPILER_IS_GNUCXX)
   set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
   message(STATUS "optional:-std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
   set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
find_package(Qt5 COMPONENTS Core REQUIRED)
find_package(Qt5DBus REQUIRED)
find_package(PkgConfig REQUIRED)

set(statusnotifierwatcher_src statusnotifierwatcher.cpp )

set(HEADERS
    systemtraytypedefs.h
    statusnotifierwatcher.h
    statusnotifieriteminterface.h
#    statusnotifierwatcherinterface.h
    dbusproperties.h
)
set(SOURCES
    systemtraytypedefs.cpp
    statusnotifierwatcher.cpp
    statusnotifieriteminterface.cpp
#    statusnotifierwatcherinterface.cpp
    dbusproperties.cpp
)

#qdbusxml2cpp
#qdbusxml2cpp org.kde.StatusNotifierWatcher.xml  -i statusnotifierwatcher.h  -c StatusNotifierWatcher
qt5_add_dbus_adaptor(${SOURCES}
    org.kde.StatusNotifierWatcher.xml
    statusnotifierwatcher.h
    StatusNotifierWatcher
)
set(statusnotifieritem_xml org.kde.StatusNotifierItem.xml)
set_source_files_properties(${statusnotifieritem_xml} PROPERTIES
   NO_NAMESPACE false
   INCLUDE "systemtraytypedefs.h"
   CLASSNAME OrgKdeStatusNotifierItemInterface
)
qt5_add_dbus_interface(${SOURCES}
    ${statusnotifieritem_xml}
    statusnotifieritem_interface
)
# qdbusxml2cpp -N -m -p dbusproperties org.freedesktop.DBus.Properties.xml
qt5_add_dbus_interface(${SOURCES}
    org.freedesktop.DBus.Properties.xml
    dbusproperties
)


add_library(${SUBLIB_NAME} ${HEADERS} ${SOURCES})
# 链接对象库
target_link_libraries( ${SUBLIB_NAME}
   PRIVATE
   Qt5::DBus
)

#aux_source_directory(. DIR_LIB_SRCS)
#add_library(statusnotifierwatcher ${DIR_LIB_SRCS})

# target_link_libraries(statusnotifierwatcher Qt5::DBus KF5::DBusAddons KF5::CoreAddons)


